<script lang="ts" setup>
import { ref } from 'vue';
import {
  MenuUnfoldOutlined,
  MenuFoldOutlined,
} from '@ant-design/icons-vue';
import { useMenu } from './menuset'
import IconPack from "@/components/utils/icon-pack.vue";
import ThemeSet from "@/components/utils/theme/ThemeSet.vue";

const menus:any = useMenu()
//侧边菜单默认激活设置
const selectedKeys = ref<string[]>(['article']);
const collapsed = ref<boolean>(false);
</script>

<template>
  <a-layout class="layout">
    <a-layout-sider v-model:collapsed="collapsed" :trigger="null" collapsible>
      <div class="logo">Linter</div>
      <a-menu v-model:selectedKeys="selectedKeys" theme="dark" mode="inline">
        <a-menu-item v-for="item in menus" :key="item.key">
          <icon-pack :icon="item.icon" :size="16" style="margin-right: .5rem"></icon-pack>
          <span><router-link :to="item.href">{{item.label}}</router-link></span>
        </a-menu-item>
      </a-menu>
    </a-layout-sider>
    <a-layout>
      <a-layout-header style="background: #fff;padding: 0" class="header-admin">
        <menu-unfold-outlined
            v-if="collapsed"
            class="trigger"
            @click="() => (collapsed = !collapsed)"
        />
        <menu-fold-outlined v-else class="trigger" @click="() => (collapsed = !collapsed)" />
        <a-space style="margin-right: 2rem;padding-left: 2rem">
          <a-avatar size="large" :style="{ backgroundColor: '#7265e6', verticalAlign: 'middle' }" :gap="1">
            Lucy
          </a-avatar>
          <span>Lucy</span>
          <ThemeSet></ThemeSet>
        </a-space>
      </a-layout-header>
      <a-layout-content class="content">
        <router-view></router-view>
      </a-layout-content>
    </a-layout>
  </a-layout>
</template>

<style>
.trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

.trigger:hover {
  color: #1890ff;
}

.logo {
  height: 32px;
  background: rgba(255, 255, 255, 0.3);
  margin: 16px;
  line-height: 32px;
  text-align: center;
  font-weight: bold;
  font-size: 1.6rem;
  color: #1890ff;
  overflow: hidden;
}
.header-admin{
  display: flex;
  justify-content: space-between;
}
.content{
  margin: 24px 16px;
  padding: 24px;
  background: #fff;
  min-height: 280px;
}
</style>
